import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/index'
import Administrators from "@/views/Administrators.vue";
import IndexView from "@/views/IndexView.vue";
import ElementUI, {Message} from 'element-ui';
import  'element-ui/lib/theme-chalk/index.css';
import ZhanghaoView from "@/views/ZhanghaoView.vue";
import ZhanginfoView from "@/views/ZhanginfoView.vue";
import NewlistView from "@/views/NewlistView.vue"
import FeedbackView from "@/views/FeedbackView.vue";
Vue.use(ElementUI);
import Axios from 'axios';
Vue.prototype.$axios = Axios;
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import http from './http'
Vue.use(VueQuillEditor);
Vue.config.productionTip = false

Vue.prototype.$http=http
Vue.prototype.$message = Message
Vue.prototype.notifySucceed = function (msg) {
  this.$notify({
    title: "成功",
    message: msg,
    type: "success",
    offset: 100
  });
};
// 封装提示失败的弹出框
Vue.prototype.notifyError = function (msg) {
  this.$notify.error({
    title: "错误",
    message: msg,
    offset: 100
  });
};
router.beforeResolve((to, from, next) => {
  const login = store.state.IsLogin;
  if (to.meta.requireAuth) {
    if (!login) {
    
      if (from.username == null) {
        next("/");
        return;
      }
      next(false);
      return;
    }
  }
  next();
});

Axios.interceptors.request.use(
  config => {
  
    return config;
  },
  error => {
    router.push({ path: "/error" });
    return Promise.reject(error);
  }
);
const routes = [
  {path: '/Administrators' , components:Administrators},
  {path: '/IndexView',components: IndexView},
  {path: '/ZhanghaoView',components: ZhanghaoView},
  {path: '/ZhanginfoView',components: ZhanginfoView},
  {path: '/NewlistView',components: NewlistView},
  {path: '/FeedbackView',components: FeedbackView}
]
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
